Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Accuracy in time #75

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open

Add Accuracy in time #75

wants to merge 13 commits into from

Conversation

Vincent-Maladiere
Copy link
Collaborator

@Vincent-Maladiere Vincent-Maladiere commented Oct 2, 2024

Address #74

Need to document and add test

hazardous/metrics/_accuracy_in_time.py Outdated Show resolved Hide resolved
hazardous/metrics/_accuracy_in_time.py Outdated Show resolved Hide resolved
hazardous/metrics/_accuracy_in_time.py Outdated Show resolved Hide resolved
hazardous/metrics/_accuracy_in_time.py Outdated Show resolved Hide resolved
hazardous/metrics/_accuracy_in_time.py Outdated Show resolved Hide resolved
hazardous/metrics/_accuracy_in_time.py Outdated Show resolved Hide resolved
hazardous/metrics/_accuracy_in_time.py Outdated Show resolved Hide resolved
hazardous/metrics/_accuracy_in_time.py Outdated Show resolved Hide resolved
examples/plot_03_competing_risks.py Outdated Show resolved Hide resolved
examples/plot_03_competing_risks.py Show resolved Hide resolved
examples/plot_03_competing_risks.py Show resolved Hide resolved
examples/plot_03_competing_risks.py Outdated Show resolved Hide resolved
examples/plot_03_competing_risks.py Show resolved Hide resolved
examples/plot_03_competing_risks.py Show resolved Hide resolved
examples/plot_03_competing_risks.py Outdated Show resolved Hide resolved
hazardous/metrics/_accuracy_in_time.py Show resolved Hide resolved
hazardous/metrics/_accuracy_in_time.py Outdated Show resolved Hide resolved
Copy link

@antoinebaker antoinebaker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the current implementation may be misleading when the time_grid does not have a good resolution (for instance small n_time_grid).

There are two tau values:

  • one used in y_test_class, it's the specified value (by quantiles or taus) and returned value as well
  • one used in y_pred_class, it's the least greater value in time_grid, given by time_grid[tau_idx]

I see two options:

  1. raise a warning if these two are too "different" (but difficult to tell what too different means as it will depend on the CIF rate of change)
  2. actually redefine and return tau = time_grid[tau_idx] used for both y_pred_class and y_test_class, in other words tau is forced to be in time_grid.

WDYT ?

hazardous/metrics/_accuracy_in_time.py Outdated Show resolved Hide resolved
hazardous/metrics/_accuracy_in_time.py Outdated Show resolved Hide resolved
hazardous/metrics/_accuracy_in_time.py Outdated Show resolved Hide resolved
Comment on lines 85 to 87
.. [Alberge2024] J. Alberge, V. Maladiere, O. Grisel, J. Abécassis, G. Varoquaux,
"Survival Models: Proper Scoring Rule and Stochastic Optimization
with Competing Risks", 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I saw an earlier remark of @judithabk6 about this, but you should update this to the aistats ref and congrats btw :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added the HAL link, for AISTATS I guess we should wait for the proceeding link? Because the PDF is not available on OpenReview anymore. WDYT?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that's a good reason to wait

hazardous/metrics/_accuracy_in_time.py Outdated Show resolved Hide resolved
for tau in taus:
mask_past_censored = (y_test["event"] == 0) & (y_test["duration"] <= tau)

tau_idx = np.searchsorted(time_grid, tau)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

time_grid needs to be sorted.

Copy link
Collaborator Author

@Vincent-Maladiere Vincent-Maladiere Jan 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, although that's a common assumption, it might be good to sort it and sort the columns of y_pred? If so, would you raise a warning? Or should we throw an error when time_grid is not sorted? 🤔

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a warning, and a reordering with a copy

hazardous/metrics/_accuracy_in_time.py Outdated Show resolved Hide resolved
@Vincent-Maladiere
Copy link
Collaborator Author

I think the current implementation may be misleading when the time_grid does not have a good resolution (for instance small n_time_grid).

You're right. To extend your suggestion 2, would you agree with dropping the taus argument entirely? So that, if quantiles are not defined, we use the grid itself, and if they are, we are assured to have tau in time_grid by doing the following:

time_grid = np.array([5, 10])
quantiles = np.array([.0, .2, .5, .8])

taus = np.quantile(time_grid, quantiles)
tau_indices = np.searchsorted(time_grid, taus)
taus = np.unique(time_grid[tau_indices])
taus
>> [5, 10]

@antoinebaker
Copy link

antoinebaker commented Jan 30, 2025

To extend your suggestion 2, would you agree with dropping the taus argument entirely? So that, if quantiles are not defined, we use the grid itself, and if they are, we are assured to have tau in time_grid by doing the following

Yes, it seems a good solution to me ! And if I remember correctly

taus = np.quantile(time_grid, quantiles, method='inverted_cdf')

does just that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants